# 读取成绩文件，计算最高最低分，计算平均分
def get_score():
    scores = []
    with open("012.txt", 'r', encoding='utf-8') as f:
        for line in f:
            # 去掉最后的换行符
            line = line[:-1]
            score = int(line.split(",")[2])
            scores.append(score)
        return scores


def score_computer(scores):
    scores = sorted(scores, reverse=True)
    max_score = scores[0]
    min_score = scores[-1]
    all_score = 0
    for i in scores:
        all_score += i
    ave_score = all_score / len(scores)

    return max_score, min_score, ave_score


a = get_score()
print(a)
print(type(a))
b = score_computer(a)
print(b)
print("max_score: %s, min_score: %s, ave_score: %s" % b)
